import { http } from "/@/utils/http";
import CryptoJS from 'crypto-js'

type Result = {
  svg?: string;
  code?: number;
  info?: object;
};

type LoginInput = {
  phoneNumber: string;
  password: string;
  tenantId: any
}

/** 获取验证码 */
export const getVerify = () => {
  return http.request<Result>("get", "/captcha");
};

/** 登录 */
export const getLogin = (data: object) => {
  return http.request("post", "/login", { data });
};

export const loginApi = (data: LoginInput) => {
  return http.request("post", "/api/auth/login", {
    data: {
      ...data,
      password: CryptoJS.MD5(data.password).toString().toLowerCase()
    }
  });
}

/** 刷新token */
export const refreshToken = (data: object) => {
  return http.request("post", "/refreshToken", { data });
};

// export const searchVague = (data: object) => {
//   return http.request("post", "/searchVague", { data });
// };
